package com.bunnyhsu.service.impl;

import com.bunnyhsu.configuration.HostConfig;
import com.bunnyhsu.mapper.ImageMapper;
import com.bunnyhsu.model.Image;
import com.bunnyhsu.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by xl on 2018/4/10.
 */
@Service
public class ImageServiceImpl implements ImageService {

    @Autowired
    private ImageMapper imageMapper;
//    @Autowired
//    private HostConfig config;

    @Override
    public String[] getImages(int id) {
        List<Image> images = imageMapper.selectImages(id);
        String[] strings = new String[images.size()];
        for(int i = 0 ; i < images.size() ; i++)
        {
            strings[i] = images.get(i).getUrl();
        }
        return strings;
    }

    @Override
    public boolean addImages(Image image) {
        return imageMapper.insertImages(image) == 1;
    }
}
